package logic

import (
	"context"
	"fmt"
	"medi-doc/model"

	"medi-doc/doctorrpc/doctorrpc"
	"medi-doc/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DoctorShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDoctorShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DoctorShowLogic {
	return &DoctorShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DoctorShowLogic) DoctorShow(in *doctorrpc.DoctorShowRequest) (*doctorrpc.DoctorShowResponse, error) {
	// todo: add your logic here and delete this line

	var doctor model.Doctor
	model.DB.Debug().Where("id=?", in.Id).Find(&doctor)
	if in.Id == 0 {
		return nil, fmt.Errorf("无数据")
	}
	model.DB.Debug().First(&doctor)
	return &doctorrpc.DoctorShowResponse{
		Id:      int64(doctor.ID),
		Name:    doctor.Name,
		Img:     doctor.Img,
		Address: doctor.Address,
		Zw:      doctor.Zw,
		Class:   doctor.Class,
		Bq:      doctor.Bq,
	}, nil
}
